require "Cocos2d"

-- cclog
local cclog = function(...)
    print(string.format(...))
end

-- for CCLuaEngine traceback
function __G__TRACKBACK__(msg)
    cclog("----------------------------------------")
    cclog("LUA ERROR: " .. tostring(msg) .. "\n")
    cclog(debug.traceback())
    cclog("----------------------------------------")
    return msg
end

local function main()
    collectgarbage("collect")
    -- avoid memory leak
    collectgarbage("setpause", 100)
    collectgarbage("setstepmul", 5000)

    if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_WINDOWS then        
        --cc.FileUtils:getInstance():addSearchPath("../../../Last/svn/mingyue/stg/src/data/lua");

        cc.FileUtils:getInstance():addSearchPath("../../../svn/mingyue/stg/src/data/lua");
    end
    cc.FileUtils:getInstance():addSearchPath("data/lua");
    require "game"

    Start();
end

local status, msg = xpcall(main, __G__TRACKBACK__)
if not status then
    error(msg)
end
